<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        // 静态注册表单提交事务
        function onsubmitFun(){
            alert("静态注册表单提交事件");
            return false;
        }

        window.onload = function(){
            let formObj = document.getElementById("form01");
            formObj.onsubmit = function (){
                alert("动态注册表单提交事件----发现不合法");

                return false;
            }
        }
    </script>
</head>
<body>
    <form action="https://www.baidu.com" method="get" onsubmit="return onsubmitFun();">
        <input type="submit" value="静态注册">
    </form>
    <form action="https://www.baidu.com" method="get" id="form01">
        <input type="submit" value="动态注册">
    </form>
</body>
</html>